<style>
 
.textarea #AppForumCommentBody   {
    height: 90px;
    width: 400px;
}
#AppForumComment_wrapper{
	margin-top:5px;
}
#AppForumCommentAddForm div {
    padding-bottom: 5px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 0px;
}

#AppForumComment_list .AppForumComment_item {
	padding:10px 19px 4px;
	_border-top:none;
}
.AppForumComment_item .AppForumComment_selected {
	background-color:#F5F8FD;
}
#AppForumComment_list .AppForumComment_more {
	padding:0;
}
#AppForumComment_list .AppForumComment_more div {
	margin:0 10px;
	padding:10px;
	font-size:14px;
	text-align:center;	
}
.AppForumComment_item .t_info {
	color:#666666;
	line-height:20px;
	float:left;
	font-size:12px;
}
.AppForumComment_item .t_info .t_username {
	color:#25343b;
	padding-left:15px;
	background:transparent url(http://i3.sinaimg.cn/dy/2010/0610/2010610122226.gif) no-repeat scroll -150px -56px;
}

.AppForumComment_item .t_info .t_area {
	color:#999;
	padding-left:15px;
	display:block;
	width:96px;
}
.AppForumComment_item .t_info .t_mobile {
	background:transparent url(http://i3.sinaimg.cn/dy/2010/0610/2010610122226.gif) no-repeat scroll 0px -56px;
}
.AppForumComment_item .t_txt {
	line-height:24px;
	margin-left:124px;
	font-size:14px;
	color:#414159;
}
.AppForumComment_item .t_others {
	margin-left:124px;
}
.AppForumComment_item .t_others .datetime {
	color: #d0d0d0;
	font-size:12px;
	margin-top:10px;
}
.AppForumComment_item .AppForumComment_selected .t_others .datetime {
	color: #999;
}
.AppForumComment_item .t_others .reply {
	float:right;
	display:none;
}
#AppForumCommentAddForm label {margin-right:3px;}
#AppForumCommentAddForm .submit{
	text-align:right;
}

.AppForumCommentBox h2 {
	height:28px;
	line-height:26px;
	padding:10px 20px 0;
	background-color:#F5F8FD;
}
.AppForumCommentBox h2 .title {
	float:left;
	font-size:18px;
	line-height:18px;
	_line-height:24px;
	font-weight:bold;
	font-family:微软雅黑,黑体;
	_font-weight:normal;
	padding-left:24px;
	color:#464646;
}
</style>
<div id="AppForumComment_wrapper">
	<div id="AppForumComment_list">
		<div id="AppForumComment_items">
		</div>
		<div class="AppForumComment_item AppForumComment_more">
			
		</div>
	</div>
	<div class="AppForumCommentBox">		
		{{$this->Form->create('AppForumComment',array('id'=>'AppForumCommentAddForm','action'=>'add','onsubmit'=>'return submitaddAppForumComment(this);','class'=>"cmt-body",'role'=>"form",))}}
		   <div class="form-group">
		   	{{$this->Form->hidden('thread_id',array('value'=>$thread_id))}}
		   	{{$this->Form->hidden('app_id',array('value'=>$app_id))}}
		   	{{$this->Form->hidden('forum_id',array('value'=>$forum_id))}}
		     <textarea id="AppForumCommentBody" placeholder="{{__('Enter your AppForumComment here')}}" rows="3" name="data[AppForumComment][content]" class="form-control"></textarea>
		   </div>
		   <div class="form-group">
		   <button class="btn btn-primary btn-sm" type="submit">{{__('Submit AppForumComment')}}</button>
		   </div>
		</form>
	</div>
</div>
<script type="text/javascript">

function loadAppForumCommentData(){
	$.ajax({
		async:true,
		type:'get',
		success:function(request, xhr) {
			for(var i in request){
				addCommintItem(request[i]['AppForumComment']);
			}
		},
		url:"/app_forum_comments/getlist.json?thread_id={{$thread_id}}&app_id={{$app_id}}&forum_id={{$forum_id}}",		
		dataType:'json'
	});
}
loadAppForumCommentData();

function addCommintItem(item){
	var str = '<div newsid="27-1-699265" channel="jc" class="AppForumComment_item">'
+'<div class="t_info">'
+'<span class="t_username">'+item['username']+'</span><br><span class="t_area"></span>'
+'</div>'
+'<div class="t_txt">'+item['content']+'</div>'
+'<div class="t_others">'
+'<span class="reply" style="display: none;">'
+'<a onclick="return false;" style="margin-right:18px;" href="#">回复</a>'
+'<a onclick="return false;" style="margin-right:0px;" href="#">支持</a>'
+'</span>'
+'<span class="datetime">'+item['created']+'</span>'
+'</div>'
+'<div style="clear:both"></div>'
+'</div>';
	$('#AppForumComment_items').append(str);
	$('#AppForumCommentBody').val('');
}

function submitaddAppForumComment(form){
	if(!sso.check_userlogin({"callback":submitaddAppForumComment,"callback_args":arguments}))
		return false;
		
	$.ajax({
		async:true,
		type:'post',
		success:function(request, xhr) {
			if(request.success){
				showSuccessMessage(request.success);
				if(request['AppForumComment']){
					addCommintItem(request['AppForumComment']);
				}
			}
			else{
				showErrorMessage(errorinfo);				
			}
		},
		url:"{{$this->Html->url(array('controller'=>'app_forum_comments','action'=>'add'))}}",
		data:$(form).serialize(),
		dataType:'json'
	}) ;
	return false;
}
//]]>
</script>